-
Notifications
You must be signed in to change notification settings - Fork 1.8k
ci: skip running builds and tests if no code changed #8768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
/kind misc |
|
Note that the tests will still run on this PR since Github Actions only applies the rules from workflows as defined in the target branch. |
.github/workflows/ci.yaml
Outdated
| on: [pull_request] # yamllint disable-line rule:truthy | ||
| on: | ||
| pull_request: | ||
| paths-ignore: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation for the paths-ignore configuration is here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a good start I think
.github/workflows/ci.yaml
Outdated
| on: | ||
| pull_request: | ||
| paths-ignore: | ||
| - 'docs/**' # If the PR only modifies the documentation, there is no need to run builds and code tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option here which which would reduce the runs even more would be to instead use '**.md, since that would include things like README.md or roadmap.md. However I am not sure if that is too liberal a policy. There are a number of other markdown files in the repo for which changes may warrant running tests for reasons I am not privy to.
$ find . -name '*md' | rg -v ./vendor | rg -v ./docs
./.github/ISSUE_TEMPLATE/feature-request.md
./.github/ISSUE_TEMPLATE/free-form.md
./.github/ISSUE_TEMPLATE/promotion-request.md
./.github/ISSUE_TEMPLATE/bug-report.md
./.github/pull_request_template.md
./cmd
./cmd/entrypoint/README.md
./cmd/nop/README.md
./code-of-conduct.md
./examples/README.md
./hack/README.md
./tekton/README.md
./tekton/release-cheat-sheet.md
./test/custom-task-ctrls/wait-task-beta/README.md
./test/custom-task-ctrls/wait-task-beta/cmd
./test/resolver-with-timeout/README.md
./test/README.md
./topical-ownership.md
./CONTRIBUTING.md
./api_compatibility_policy.md
./roadmap.md
./DEVELOPMENT.md
./README.md
./releases.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think **md should be ok but depends on if any of the tests are testing the md files as you mentioned. Once we know that for sure we can use **md. +1 for the current defensive approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think we have some checks on the docs (like deadlink) or we used to.
Out of curiosity, can we skip some jobs instead ? Worst case, we could have a "docs" workflow with the opposite filter.
|
Yeah if there are docs CI tests we can use a separate filter. Do you know where the docs tests are found or called? I didn't see any inside this file, and outside of verify-codegen it looked like all the tests were unit tests |
.github/workflows/ci.yaml
Outdated
| on: [pull_request] # yamllint disable-line rule:truthy | ||
| on: | ||
| pull_request: | ||
| paths-ignore: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a good start I think
.github/workflows/ci.yaml
Outdated
| on: | ||
| pull_request: | ||
| paths-ignore: | ||
| - 'docs/**' # If the PR only modifies the documentation, there is no need to run builds and code tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think **md should be ok but depends on if any of the tests are testing the md files as you mentioned. Once we know that for sure we can use **md. +1 for the current defensive approach.
|
/approve |
|
@vdemeester: GitHub didn't allow me to request PR reviews from the following users: AlanGreene. Note that only tektoncd members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a couple of yaml files under docs
➜ find docs -name '*yaml'
docs/resolver-template/config/demo-resolver-deployment.yaml
docs/resolver-template/test-resolver-template.yaml
Perhaps we could move the yaml linter under a dedicated job along with the markdown linter. Do we do markdown linting? I though we did but cannot find it....
.github/workflows/ci.yaml
Outdated
| on: | ||
| pull_request: | ||
| paths-ignore: | ||
| - 'docs/**' # If the PR only modifies the documentation, there is no need to run builds and code tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem I still see is that the skip here is for the entire set of jobs, and I think we should still run yamllint on the docs.
|
Hi @aThorp96, let me know if you have any updates on this one. This is a simple one so was hoping to get it merged soon. |
|
@aThorp96 needs a rebase 👼🏼 |
|
We can carry this if need be. |
|
I think this will block PRs since the jobs are still required. The common approach is to skip the jobs using Update: GitHub recommended approach: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks Warning If a workflow is skipped due to path filtering, branch filtering or a commit message, then checks associated with that workflow will remain in a "Pending" state. A pull request that requires those checks to be successful will be blocked from merging. If, however, a job within a workflow is skipped due to a conditional, it will report its status as "Success". For more information, see Using conditions to control job execution. When a job fails, any jobs that depend on the failed job are skipped and do not report a failure. A pull request that requires the check may not be blocked. To use a required check on a job that depends on other jobs, use the always() conditional expression in addition to needs, see Using jobs in a workflow. |
bac9ec7 to
f646f2b
Compare
|
@aThorp96 can you take @AlanGreene's comment into account ? |
|
@AlanGreene Thanks for catching that. This should be trivial to do with an external action like dorny/paths-filter. I could write a step to do this with shell as well if we don't want to add an external action dependency. Any preference? |
I don't mind the external dependency, however the last commit on https://github.com/dorny/paths-filter was last year, which could be a red flag. Even if the action is in "problem solved" state, it should feature Dependabot updates or so. New PRs seem to have been ignored. Is there any other alternative? |
f646f2b to
05be37a
Compare
dbc097b to
9e111fa
Compare
6beeb8a to
4b62a88
Compare
.github/workflows/ci.yaml
Outdated
| on: | ||
| - pull_request | ||
| pull_request: | ||
| paths-ignore: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aThorp96 This should be removed then right ?
f786310 to
f96ed24
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vdemeester, waveywaves The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Not ready to merge yet. Since I modified non-docs files (esp since I modified the build CI) it should have triggered a build. |
|
Ah it should have run a yamllint, but nothing more I guess, isn't it ? you changed the CI but to skip the CI.. /hold |
| only-new-issues: true | ||
| args: --timeout=10m | ||
| - name: yamllint | ||
| if: ${{ needs.changes.outputs.yaml == 'true' }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, however I'm mostly concerned with E2E test. We should skip them if they're not relevant as they take a lot of runners and time. Everything else is small/quick enough that I would not bother touching it at the risk of over-optimising.
f96ed24 to
2187710
Compare
|
@vdemeester @afrittoli This appears to be working as expected now. |
2187710 to
f8fdb02
Compare
f8fdb02 to
fe9b6b2
Compare
| - name: Get base depth | ||
| id: base-depth | ||
| run: echo "base-depth=$(expr ${{ github.event.pull_request.commits }} + 1)" >> $GITHUB_OUTPUT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could clone the full repository here, but that could take some time and is probably not necessary. This should help the pre-check go much quicker
|
/retest |
fe9b6b2 to
a097c84
Compare
Changes
Skip running builds and tests on pull requests if the pull request only changes documentation. From what I can tell, there are no e2e tests in use right now triggered by the
Tekton Integrationworkflow which analyze the markdown docs files except the codegen test which checks to ensure the Pipeline api file was updated, however that should only be updated if the pipelines api is changed in the code. The tests themselves take some time. Also, while the Workflows may be free for compute since they're on GHA, they are still unnecessary and if the e2e tests use any ancillary services which have cost (maybe caching, coverage, image hosting, etc) unnecessary runs at least have the potential of incurring cost.Submitter Checklist
As the author of this PR, please check off the items in this checklist:
/kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes